<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<ui:composition template="/templatePrincipal.xhtml" xmlns="http://www.w3.org/1999/xhtml"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:a4j="http://richfaces.org/a4j"
                xmlns:s="http://jboss.com/products/seam/taglib"
                xmlns:rich="http://richfaces.org/rich">

    <ui:define name="conteudo">
        <script type="text/javascript">
            function limparCampos(){
                document.getElementById("fpJogos:calendarJogo").value = '';
                document.getElementById("fpJogos:somTime1").selectedIndex = 0;
                document.getElementById("fpJogos:somTime2").selectedIndex = 0;
            }
        </script>
        <rich:spacer height="20"/>
        <center>
            <rich:messages layout="table"
                           errorClass="errorClass"
                           infoClass="infoClass"
                           warnClass="warnClass"
                           styleClass="painelMensagem"
                           ajaxRendered="true"/>
        </center>
        <rich:spacer height="10"/>
        <rich:panel switchType="client">
            <f:facet name="header">
                Cadastro de Jogo
            </f:facet>
            <h:form id="fpJogos">
                <h:panelGrid cellspacing="2" cellpadding="2" columns="2" columnClasses="field-names, fields">
                    <h:outputLabel styleClass="required-black">
                        Data do Jogo
                    </h:outputLabel>
                    <a4j:outputPanel id="calendarJogo" style="width:70px;">
                        <rich:calendar value="#{jogoCadastroAction.paramDataJogo}"
                                       locale="BR"
                                       required="true"
                                       requiredMessage="#{messages['data.obrigatoria']}"
                                       datePattern="dd/MM/yyyy"/>
                    </a4j:outputPanel>
                </h:panelGrid>

                <h:panelGrid cellspacing="2" cellpadding="2" columns="3">
                    <h:outputLabel for="somTime1" styleClass="required-black">
                        Time 1
                    </h:outputLabel>

                    <h:selectOneMenu id="somTime1" value="#{jogoCadastroAction.equipeSelecionada}" required="true" requiredMessage="#{messages['time1.obrigatorio']}">
                        <s:selectItems value="#{jogoCadastroAction.listaEquipes}" var="e" label="#{e.nome}" itemValue="#{e.idEquipe}" noSelectionLabel="..." />
                    </h:selectOneMenu>
                </h:panelGrid>


                <h:panelGrid cellspacing="2" cellpadding="2" columns="2" columnClasses="field-names, fields">
                    <h:outputLabel for="somTime2" styleClass="required-black">
                        Time 2
                    </h:outputLabel>
                    <h:selectOneMenu id="somTime2" required="true" requiredMessage="#{messages['time2.obrigatorio']}" value="#{jogoCadastroAction.equipe2Selecionada}">
                        <s:selectItems value="#{jogoCadastroAction.listaEquipes}" var="e" label="#{e.nome}"
                                       itemValue="#{e.idEquipe}" noSelectionLabel="..." />
                    </h:selectOneMenu>
                </h:panelGrid>
                <br/>
                <h:commandLink id="clCriar"
                               action="#{jogoCadastroAction.cadastrarJogo}"
                               styleClass="link dr-toolbar-ext rich-toolbar">
                    <h:graphicImage value="/resources/images/dialog-ok-old.png"/>
                    <h:outputText value="Salvar"/>
                </h:commandLink>

                <h:commandLink id="clLimpar"
                               immediate="true"
                               onclick="limparCampos()"
                               styleClass="link dr-toolbar-ext rich-toolbar">
                    <h:graphicImage value="/resources/images/edit-clear.png"/>
                    <h:outputText value="Limpar"/>
                </h:commandLink>
            </h:form>
        </rich:panel>
    </ui:define>
</ui:composition>